<?php

/**
 * Contact form base class.
 *
 * @method Contact getObject() Returns the current form's model object
 *
 * @package    SdCommerce
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseContactForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'nom'            => new sfWidgetFormInputText(),
      'prenom'         => new sfWidgetFormInputText(),
      'fonction'       => new sfWidgetFormInputText(),
      'telephone'      => new sfWidgetFormInputText(),
      'gsm'            => new sfWidgetFormInputText(),
      'fax'            => new sfWidgetFormInputText(),
      'email'          => new sfWidgetFormInputText(),
      'id_client'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Client'), 'add_empty' => true)),
      'id_fournisseur' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Fournisseur'), 'add_empty' => true)),
      'civilite'       => new sfWidgetFormChoice(array('choices' => array('M' => 'M', 'Mme' => 'Mme', 'Mlle' => 'Mlle'))),
      'departement'    => new sfWidgetFormInputText(),
      'created_at'     => new sfWidgetFormDateTime(),
      'updated_at'     => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'nom'            => new sfValidatorString(array('max_length' => 30)),
      'prenom'         => new sfValidatorString(array('max_length' => 30)),
      'fonction'       => new sfValidatorString(array('max_length' => 30)),
      'telephone'      => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'gsm'            => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'fax'            => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'email'          => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'id_client'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Client'), 'required' => false)),
      'id_fournisseur' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Fournisseur'), 'required' => false)),
      'civilite'       => new sfValidatorChoice(array('choices' => array(0 => 'M', 1 => 'Mme', 2 => 'Mlle'), 'required' => false)),
      'departement'    => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'created_at'     => new sfValidatorDateTime(),
      'updated_at'     => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('contact[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Contact';
  }

}
